Ext
		.onReady(function() {

			Ext.BLANK_IMAGE_URL = '/EjemploVersionado/ext-3.3.1/resources/images/default/s.gif';

			var Tipo = Ext.data.Record.create([ {
				name : 'idtipo'
			}, {
				name : 'tiponombre',
				type : 'string'
			}, {
				name : 'tipodescripcion',
				type : 'string'
			} ]);

			var proxy = new Ext.data.HttpProxy({
				api : {
					read : 'tipo/view.action',
					create : 'tipo/create.action',
					update : 'tipo/update.action',
					destroy : 'tipo/delete.action'
				}
			});

			var reader = new Ext.data.JsonReader({
				totalProperty : 'total',
				successProperty : 'success',
				idProperty : 'idtipo',
				root : 'data',
				messageProperty : 'message' // <-- New "messageProperty"
			// meta-data
			}, Tipo);

			// The new DataWriter component.
			var writer = new Ext.data.JsonWriter({
				encode : true,
				writeAllFields : true
			});

			// Typical Store collecting the Proxy, Reader and Writer together.
			var store = new Ext.data.Store({
				id : 'user2',
				proxy : proxy,
				reader : reader,
				writer : writer, // <-- plug a DataWriter into the store just
				// as you would a Reader
				autoSave : false
			// <-- false would delay executing create, update, destroy requests
			// until specifically told to do so with some [save] buton.
			});

			// read the data from simple array
			store.load();

			Ext.data.DataProxy.addListener('exception', function(proxy, type,
					action, options, res) {
				Ext.Msg.show({
					title : 'ERROR',
					msg : res.message,
					icon : Ext.MessageBox.ERROR,
					buttons : Ext.Msg.OK
				});
			});

			var editor = new Ext.ux.grid.RowEditor({
				saveText : 'Actualiza u.u'
			});

			// create grid
			var grid = new Ext.grid.GridPanel({
				store : store,
				columns : [ {
					header : "Id",
					width : 170,
					sortable : true,
					dataIndex : 'idtipo',
					editor : {
						xtype : 'textfield',
//						allowBlank : false,
//						disabled : true
						readOnly: true
					}
				}, {
					
					header : "Tipo",
					width : 160,
					sortable : true,
					dataIndex : 'tiponombre',
//					editor : {
//						xtype : 'textfield',
//						allowBlank : false
//					}
//					editor   : {xtype:'combo', 
//                        store: new Ext.data.ArrayStore({
//                               fields: ['abbr', 'action'],
//                               data : [                                         
//                                       ['suspend', 'Suspend'],
//                                       ['activate', 'Activate'],
//                                       ['update', 'Update'],
//                                       ['delete', 'Delete']
//                                      ]
//                                }),
//                               displayField:'action',
//                               valueField: 'abbr',
//                               mode: 'local',
//                              typeAhead: false,
//                              triggerAction: 'all',
//                              lazyRender: true,
//                              emptyText: 'Select action'
//                        }
					editor   : {xtype:'combo', 
                        store: store,
                               displayField:'tiponombre',
                               valueField: 'tiponombre',
                               mode: 'local',
                              typeAhead: false,
                              triggerAction: 'all',
                              lazyRender: true,
                              emptyText: 'Select action',
//                              readOnly: true
                              editable: false
                        }
				
				}, {
					header : "Descripcion",
					width : 170,
					sortable : true,
					dataIndex : 'tipodescripcion',
					editor : {
						xtype : 'textfield',
						allowBlank : false
					}
				} ],
				viewConfig : {
					forcefit : true
				},
				plugins : [ editor ],
				title : 'Mis Tipos',
				height : 300,
				width : 835,
				frame : true,
				tbar : [ {
					iconCls : 'icon-user-add',
					text : 'Agregar Tipo',
					handler : function() {
						var e = new Tipo({
							name : 'Nuevo Tipo',
							phone : '(000) 000-0000',
							email : 'new@rhandyprueba.com'
						});
						editor.stopEditing();
						store.insert(0, e);
						grid.getView().refresh();
						grid.getSelectionModel().selectRow(0);
						editor.startEditing(0);
					}
				}, {
					iconCls : 'icon-user-delete',
					text : 'Remover Tipo',
					handler : function() {
						editor.stopEditing();
						var s = grid.getSelectionModel().getSelections();
						for (var i = 0, r; r = s[i]; i++) {
							store.remove(r);
						}
					}
				}, {
					iconCls : 'icon-user-save',
					text : 'Guardar todo !!',
					handler : function() {
						store.save();
					}
				} ]
			});

			// render to DIV
			grid.render('tipocrud-grid');
		});